<extend name="Public/base"/>

<block name="body">
	<script type="text/javascript" src="__STATIC__/kindeditor/kindeditor-min.js"></script>
    <script type="text/javascript" src="__STATIC__/kindeditor/zh_CN.js"></script>
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title">
		<h2>{:isset($info['id'])?'编辑':'新增'}菜单</h2>
	</div>
	<div class="tab-wrap">
		<ul class="tab-nav nav">
			<li data-tab="tab1" class="current"><a href="javascript:void(0);">基 础</a></li>
			<li data-tab="tab2" style="display:none;"><a href="javascript:void(0);">高 级</a></li>
		</ul>
		<div class="tab-content">
			<form action="{:U()}" method="post" class="form-horizontal">
				<!-- 基础 -->
				<div id="tab1" class="tab-pane in tab1">
					<div class="form-item">
                            <label class="item-label">上级菜单<span class="check-tips">（所属的上级菜单）</span></label>
                            <div class="controls">
                                <select name="category_id">
                                    <volist name="catelist" id="cate">
                                        <option value="{$cate.id}">{$cate.title_show}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
					<div class="form-item">
						<label class="item-label">
							名称<span class="check-tips">（名称不能为空）</span>
						</label>
						<div class="controls">
							<input type="text" name="name" class="text input-large" value="{$info.name|default=''}">
						</div>
					</div> 
                    <div class="controls">
						<label class="item-label">封面(721px*259px)</label>
						<input type="file" id="upload_picture" class="upload_picture" uploadwidth="721" />
						<input type="hidden" name="front_pic" id="front_pic" class="upload_input" value="{$info['front_pic']|default=''}"/>
						<div class="upload-img-box">
						<notempty name="info['front_pic']">
							<div class="upload-pre-item" style="width:721px; max-height:300px;"><a href="{$info.front_pic}" target="_blank"><img src="{$info.front_pic}"  /></a></div>
						</notempty>
						</div>
					</div>
                     <div class="controls">
						<label class="item-label">封面按钮(721px*64px)</label>
						<input type="file"   class="upload_picture" id="upload_pictrue2" uploadwidth="721" />
						<input type="hidden" name="front_btn_pic" id="front_btn_pic" class="upload_input" value="{$info['front_btn_pic']|default=''}"/>
						<div class="upload-img-box">
						<notempty name="info['front_btn_pic']">
							<div class="upload-pre-item" style="width:721px; max-height:300px;"><a href="{$info.front_btn_pic}" target="_blank"><img src="{$info.front_btn_pic}"  /></a></div>
						</notempty>
						</div>
					</div>
                    <div class="controls">
                    	
						<label class="item-label"><input type="radio" name="url_type" value="2" checked />&nbsp;&nbsp;活动长图(750px宽)</label>
						<input type="file"   class="upload_picture" id="upload_pictrue3" uploadwidth="721" />
                        <input type="hidden" name="url" id="url" class="upload_input" value="{$info['url']|default=''}"/>
                        <div class="upload-img-box">
						<notempty name="info['url']">
							<div class="upload-pre-item"><a href="{$info.url}" target="_blank"><img src="{$info.url}"/></a></div>
						</notempty>
						</div>
                        <input type="radio" name="url_type" value="1" />&nbsp;&nbsp;活动链接:<br/><input type="text" id="act_url" name="act_url" value="{$info['act_url']}" class="text input-big" style="width:600px;" />
						
						
					</div>
                    
					<div class="form-item">
						<label class="item-label">
							排序<span class="check-tips">（仅对当前层级菜单有效）</span>
						</label>
						<div class="controls">
							<input type="text" name="orderno" class="text input-small" value="{$info.orderno|default=0}">
						</div>
					</div>
                    <div class="form-item">
						<label class="item-label">
							显示<span class="check-tips">（1表示显示，0表示隐蔽）</span>
						</label>
						<div class="controls">
							<input type="text" name="isshow" class="text input-small" value="{$info.isshow|default=1}">
						</div>
					</div>
                    <div class="form-item">
						<label class="item-label">
							数据文本内容<span class="check-tips"></span>
						</label> 
							<label class="textarea" style="width:600px; ">
                            <textarea name="content" id="content"  >{$info.content}</textarea> 
                            {:hook('adminArticleEdit',array("name"=>"content","value"=>$info['content']))}
                            </label> 
					</div>
					 <div class="form-item">
						<label class="item-label">
							用户名<span class="check-tips">（不填写表示不用验证，长度必须大于3位）</span>
						</label>
						<div class="controls">
							<input type="text" name="username" class="text input-large" value="{$info.username|default=''}">
						</div>
					</div> 
                    <div class="form-item">
						<label class="item-label">
							密码<span class="check-tips">（长度必须大于3位）</span>
						</label>
						<div class="controls">
							<input type="text" name="password" class="text input-large" value="{$info.password|default=''}">
						</div>
					</div> 
					<script type="text/javascript">
					//上传图片
					
					jQuery(".upload_picture").each(function(index, element) { 
                        jQuery(this).uploadify({
							"height"          : 30,
							"swf"             : "__STATIC__/uploadify/uploadify.swf",
							"fileObjName"     : "download",
							"buttonText"      : "上传图片",
							"uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}&div_id="+jQuery(this).attr("id"),
							"width"           : 120,
							'removeTimeout'	  : 1,
							'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
							"onUploadSuccess" : uploadPicture,
							'onFallback' : function() {
								alert('未检测到兼容版本的Flash.');
							}
						});
                    }); 
					
					 
				    
					function uploadPicture(file, data){ 
				    	var data = $.parseJSON(data);
				    	var src = '';
				        if(data.status){ 
							var _picObj = $("#"+data.div_id).parent().find(".upload_input");
				        	
				        	src = data.url || '__ROOT__' + data.path;
							_picObj.val(src);
				        	_picObj.parent().find('.upload-img-box').html(
				        		'<div class="upload-pre-item" style="width:721px; max-height:300px"><a href="'+src+'" target="_blank"><img src="' + src + '"/></a></div>'
				        	);
				        } else {
				        	updateAlert(data.info);
				        	setTimeout(function(){
				                $('#top-alert').find('button').click();
				                $(that).removeClass('disabled').prop('disabled',false);
				            },1500);
				        }
				    }
					</script>
				</div>

				 

				<div class="form-item">
					<input type="hidden" name="id" value="{$info.id|default=''}"> 
					<button type="submit" id="submit" class="btn submit-btn ajax-post" target-form="form-horizontal">确 定</button>
					<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
				</div>
			</form>
		</div>
	</div>
</block>

<block name="script">
	<script type="text/javascript">
		<present name="info.id">
		Think.setValue("category_id", {$info.category_id|default=0});
		Think.setValue("url_type", {$info.url_type|default=2});
		 
		</present>
		$(function(){
			showTab();
			$("input[name=reply]").change(function(){
				var $reply = $(".form-item.reply");
				parseInt(this.value) ? $reply.show() : $reply.hide();
			}).filter(":checked").change();
		});
		//导航高亮
		highlight_subnav('{:U('Banner/index')}');
		
		
	</script>
</block>
